{include file="head.html"}
<style>
.table_style td { border-bottom:1px #ddd solid;}
.libel_list {background-color:#f5f5f5; border:1px #ccc solid;  padding:5px;}
.libel_list a { padding-left:10px; float:left; padding-right:10px; line-height:22px; height:22px; background-color:#fefefe; border:1px #ddd solid; margin-top:3px;margin-right:10px;}
.title_width { width:120px; line-height:25px; float:left;}
.listcontent { width:300px; float:left;}
#echo { line-height:20px; font-size:12px;}
</style>
<script src="__PUBLIC__/js/insertContent.js"></script>
<div id="maincontent">
  <div class="wrap">
    <div class="tip"> {lang='添加标签后会自动生成相应标签，把标签放入模板需要位置即可。'} </div>
    <form action="__URL__/add" id="form" method="post">
      <div class="infobox">
        <h3>{lang='内容标签添加'}</h3>
        <table class="form-table table_style">
          <tr>
            <td><strong>{lang='标签信息'}：</strong></td>
          </tr>
          <tr>
            <td><div class="title_width">{lang='标签名称'}：</div>
              <input name="name" type="text" class="regular-text" id="name" /></td>
          </tr>
          <tr>
            <td><div class="title_width">{lang='标签标识'}：</div>
              <input name="label" type="text" class="regular-text" id="label" /></td>
          </tr>
          <tr>
            <td><strong>{lang='调用参数'}：</strong></td>
          </tr>
          <tr>
            <td><select name="mid" id="mid"  >
                <option value="none">{lang='全部模型'}</option>
                <?php if(!empty($modlist)) foreach($modlist as $vo){ ?>
                <option value="{$vo['id']}">{$vo['name']}</option>
                <?php } ?>
              </select>
              <input name="cid" type="text" class="regular-text" id="cid" style="width:120px;" />
              <select style="width:130px;" onChange="$('#cid').val(decodeURIComponent($(this).val()))"  >
                <option value="" selected="selected">{lang='全部栏目'}</option>
                <option value="#%5Bchannel_info:id%5D#">{lang='字段ID(示例)'}</option>
                <option value="">====================</option>
                <?php if(!empty($cat)) foreach($cat as $vo){ ?>
                <option value="{$vo['id']}">{$vo['cname']}</option>
                <?php } ?>
              </select>
              <select name="sub" id="sub">
                <option value="none">{lang='(子栏目)'}</option>
                <option value="none">{lang='不包含'}</option>
                <option value="true">{lang='包含'}</option>
              </select></td>
          </tr>
          <tr>
            <td><input name="limit" type="text" class="regular-text" id="limit" style="width:100px;" value="10" />
              条
              <select name="pic" id="pic" >
                <option value="none">{lang='不限(缩略图)'}</option>
                <option value="true">{lang='带有缩略图'}</option>
                <option value="false">{lang='不带有缩略图'}</option>
              </select>
              <select name="hits" id="hits" >
                <option value="none">{lang='不限(置顶)'}</option>
                <option value="true">{lang='是(置顶)'}</option>
              </select>
              <select name="good" id="good" >
                <option value="none">{lang='不限(推荐)'}</option>
                <option value="true">{lang='是(推荐)'}</option>
              </select></td>
          </tr>
          <tr>
            <td><input name="order" type="text" class="regular-text" id="order" style="width:200px;" value="id desc" />
              <select onChange="$('#order').val($(this).val())">
                <option value="id desc" selected="selected">{lang='内容按ID倒序排序'}</option>
                <option value="id asc">{lang='内容按ID升序排序'}</option>
                <option value="time desc">{lang='按照发布时间倒序排序'}</option>
                <option value="time asc">{lang='按照发布时间升序排序'}</option>
                <option value="sorter desc">{lang='按照自定义排序倒序排序'}</option>
                <option value="sorter asc">{lang='按照自定义排序升序排序'}</option>
              </select></td>
          </tr>
          <tr>
            <td><strong>{lang='附加SQL条件'}：</strong>({lang='附件条件为标准的SQL和PHP语法，条件中"A"代表定义的A表也就是内容表，"B"代表栏目表，"C"代表扩展模型表(如果存在)。'})</td>
          </tr>
          <tr>
            <td><input name="where" type="text" class="regular-text" id="where" />
              <select onChange="$('#where').val($(this).val())">
                <option value="">{lang='无'}</option>
                <option value="A.hits=1">{lang='查询推荐内容(示例)'}</option>
              </select></td>
          </tr>
          <tr>
            <td><strong>{lang='循环标识'}：</strong>({lang='如果为多维循环循环标识不能相同，多维循环请点击"插入循环标签"插入在外部循环内。'})</td>
          </tr>
          <tr>
            <td><input name="mark" type="text" class="regular-text" id="mark" style="width:100px;" value="list" /></td>
          </tr>
          <tr>
            <td><button type="button" onclick="out_label(1)">{lang='输出栏目标签'}</button>
              <button type="button" onclick="out_label(2)">{lang='插入栏目标签'}</button>
              <button type="button" onclick="out_label(3)">{lang='清空标签'}</button></td>
          </tr>
          <tr>
            <td> {lang='复杂示例'}：<a href="javascript:void(0)" onclick="demo_label(1)">{lang='输出顶级栏目内的内容循环'}</a>{lang='(多维循环)'} </td>
          </tr>
          <tr>
            <td><div class="libel_list">
                <div style="clear:both"></div>
                <a href="javascript:void(0)"  onclick="ins_html('id')">内容编号</a> <a href="javascript:void(0)"  onclick="ins_html('cid')">内容所属栏目编号</a> <a href="javascript:void(0)"  onclick="ins_html('title')">标题</a> <a href="javascript:void(0)"  onclick="ins_html('titlex')">标题带样式</a> <a href="javascript:void(0)"  onclick="ins_html('pinyin')">标题英文</a> <a href="javascript:void(0)"  onclick="ins_html('pic')">缩略图</a> <a href="javascript:void(0)"  onclick="ins_html('keywords')">关键词</a> <a href="javascript:void(0)"  onclick="ins_html('keywords $tag=,')">TAG</a> <a href="javascript:void(0)"  onclick="ins_html('description')">内容描述</a> <a href="javascript:void(0)" onclick="ins_html('views')">浏览量</a> <a href="javascript:void(0)" onclick="ins_html('sorter')">排序</a> <a href="javascript:void(0)" onclick="ins_html('author')">作者</a> <a href="javascript:void(0)" onclick="ins_html('time $format=Y-m-d')">发布时间</a> <a href="javascript:void(0)" onclick="ins_html('aurl')">内容超链接</a> <a href="javascript:void(0)" onclick="ins_html('curl')">栏目超链接</a> <a href="javascript:void(0)" onclick="ins_html('cname')">栏目名称</a> <a href="javascript:void(0)"  onclick="ins_html('cseoname')">栏目SEO名称</a> <a href="javascript:void(0)" onclick="ins_html('cpinyin')">栏目英文</a> <a href="javascript:void(0)" onclick="ins_html('i')">循环序号</a> <a href="javascript:void(0)" onclick="ins_html('my_字段')">扩展字段(需要自己填写)</a>
                <div style="clear:both"></div>
              </div>
              <textarea name="content" id="echo" style="width:98%; height:150px; border:1px solid #ccc; margin-top:10px;"></textarea>
              <div>{lang='点击上面各个标签按钮会插入相应的标签代码，请将代码插入循环内部。输出的标签也可直接用于模板内。'}</div></td>
          </tr>
        </table>
      </div>
      <div class="submit_body">
        <input name="type" id="type" type="hidden" value="2" />
        <button class="regular-button" type="button" onclick="post()">{lang='添加'}</button>
      </div>
    </form>
  </div>
</div>
<script>
function out_label(type) {
	
	if($('#cid').val()==""){
		var cid='';
	}else{
		var cid=' cid=('+$('#cid').val()+')'; //栏目ID
	}
	
	if($('#sub').val()=="none"){
		var classsub='';
	}else{
		var classsub=' sub=('+$('#sub').val()+')'; //是否包含子栏目
	}
	
	var limit=' limit=('+$('#limit').val()+')'; //调用条数
	
	if($('#mid').val()=="none"){
		var mid='';
	}else{
		var mid=' mid=('+$('#mid').val()+')'; //模型ID
	}
	
	var order=' order=('+$('#order').val()+')'; //排序类型
	
	if($('#pic').val()=="none"){
		var pic='';
	}else{
		var pic=' pic=('+$('#pic').val()+')'; //缩略图
	}
	
	var mark=$('#mark').val(); //循环标识
	
	if($('#hits').val()=="none"){
		var hits='';
	}else{
		var hits=' hits=('+$('#hits').val()+')'; //置顶内容
	}
	
	if($('#good').val()=="none"){
		var good='';
	}else{
		var good=' good=('+$('#good').val()+')'; //推荐内容
	}
	
	if($('#where').val()==""){
		var where='';
	}else{
		var where=' where=('+$('#where').val()+')'; //附加条件
	}
		
	
	var outhtml="<!--"+mark+":{table=(content)";
	outhtml+=cid;
	outhtml+=classsub;
	outhtml+=mid;
	outhtml+=pic;
	outhtml+=hits;
	outhtml+=good;
	outhtml+=where;
	outhtml+=order;
	outhtml+=limit;
	outhtml+="}-->\n";
	outhtml+='<a href="['+mark+':aurl]">['+mark+':title]</a>\n';
	outhtml+="<!--/"+mark+"-->";
	
	if(type==1){
	$('#echo').attr("value",outhtml);
	}
	if(type==2){
	$('#echo').insertContent(outhtml);
	}
	if(type==3){
	$('#echo').attr("value",'');
	}

};

function ins_html(content) {
	var mark=$('#mark').val(); //循环标识
	$('#echo').insertContent('['+mark+':'+content+']'); 
}

function demo_label(type) {
	if(type==1){
	var outhtml="<ul>\n<!--channel:{table=(channel) type=(top) limit=(10) order=(id desc)";
	outhtml+="}-->\n";
	outhtml+='<a href="[channel:'+'curl]">[channel'+':name]</a>\n';
	outhtml+="<!--list:{table=(content) cid=(#[channel"+":"+"id]#) limit=(10) order=(id desc)";
	outhtml+="}-->\n";
	outhtml+='<li><a href="[list'+':'+'aurl]">[list'+':'+'title]</a></li>\n';
	outhtml+="<!--/"+"list-->\n";
	outhtml+="<!--/"+"channel-->\n</ul>";
	}
	$('#echo').attr("value",outhtml);
}

 </script>
</body></html>